#coding: utf-8


class Solution:
    pair = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I']

    money = [1000, 900, 500, 400, 100, 90, 50,40,10,9,5,4,1]

    def intToRoman(self, num: int) -> str:
        length = len(self.money)
        res = ''
        for i in range(length):
            while num>=self.money[i]:
                num = num - self.money[i]
                res = res + self.pair[i]

        return res


if __name__ == '__main__':
    solu = Solution()
    print(solu.intToRoman(9))
